package com.yuanfeng.business.controller;


import com.yuanfeng.business.dto.GdbMerchantTransportTemplateDTO;
import com.yuanfeng.business.dto.ManageTransportTemplateDTO;
import com.yuanfeng.business.dto.ShippingQueryListDTO;
import com.yuanfeng.business.dto.UserTokenBeanDTO;
import com.yuanfeng.commoms.annnotation.Log;
import com.yuanfeng.commoms.util.ResponseResult;
import com.yuanfeng.commoms.vo.shop.TransportTemplateVO;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName ShopTransportTemplateController
 * @Description 运费模板表
 * @Author cyp
 * @Date 2023-05-29 13:55:17
 * @Version 1.0
 **/
@RestController
@RequestMapping("shop/transportTemplate")
public class ShopTransportTemplateController extends BaseController {

    /**
     * 查询运费
     *
     * @param message
     * @return
     */
    @PostMapping("/shipping/query")
    public ResponseResult queryShipping(@RequestParam("message") String message) {

        return shopTransportTemplateService.queryShipping(message);
    }

    /**
     * 获取商品信息 及 活动信息
     *
     * @param goodsId
     * @return
     */
    @GetMapping("/getGoodsDetails")
    public ResponseResult getGoodsDetails(@RequestParam("goodsId") Integer goodsId){
        return shopTransportTemplateService.getGoodsDetails(goodsId);
    }

    /**
     * 查询运费模板列表
     *
     * @param param
     * @return
     */
    @PostMapping("/query/list")
    public ResponseResult queryTransportTemplateList(@RequestBody UserTokenBeanDTO param) {
        return shopTransportTemplateService.queryTransportTemplateList(param);
    }


    /**
     * 删除运费模板
     *
     * @param param
     * @return
     */
    @Log("删除运费模板")
    @PostMapping("/delete")
    public ResponseResult deleteTransportTemplate(@RequestBody ManageTransportTemplateDTO param) {
        return shopTransportTemplateService.deleteTransportTemplate(param);
    }

    /**
     * 更新或新增运费模板
     *
     * @param param
     * @return
     */
    @PostMapping("/update")
    @Log("更新或新增运费模板")
    public ResponseResult updateTransportTemplate(@RequestBody GdbMerchantTransportTemplateDTO param) {
        return shopTransportTemplateService.updateTransportTemplate(param);
    }

    /**
     * 查询运费模板
     *
     * @param param
     * @return
     */
    @PostMapping("/query/detail")
    public ResponseResult queryTransportTemplateDetail(@RequestBody ManageTransportTemplateDTO param) {
        return shopTransportTemplateService.queryTransportTemplateDetail(param);
    }


    /**
     * 平台 查询某个商品运费
     *
     * @param param
     * @return
     */
    @PostMapping("/platform/shipping/query")
    public ResponseResult queryShippingQuery(@RequestBody ShippingQueryListDTO param) {
        ResponseResult result=shopTransportTemplateService.queryShippingQuery(param);
        return result;
    }

    /**
     * 查询商家运费模板
     *
     * @param transportTemplate
     * @return
     */
    @GetMapping("/selectTemplateById")
    public ResponseResult selectTemplateById(@RequestParam("transportTemplate") Integer transportTemplate) {
        return shopTransportTemplateService.selectTemplateById(transportTemplate);
    }


    /**
     * 通过店铺id查询
     *
     * @param shopId
     * @return
     */
    @GetMapping("/selectByShopId")
    public List<TransportTemplateVO> selectByShopId(@RequestParam("shopId") Integer shopId) {
        return shopTransportTemplateService.selectByShopId(shopId);
    }
}
